package com.gblw.rjkf.pj.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.gblw.rjkf.pj.service.SysDictDetailsService;
import com.gblw.rjkf.pj.service.SysMenusService;
import com.gblw.rjkf.pj.service.SysUserService;
import com.gblw.rjkf.pj.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
public class LoginController {
    @Resource
    private SysUserService sysUserService;
    @Resource
    private SysMenusService sysMenuService;
    @Resource
    private SysDictDetailsService sysDictDetailsService;

//    @RequestMapping("login")
//    public Result login(@RequestBody SysUser sysUser) {
//
//        return sysUserService.getUserSign(sysUser);
//    }
    // 获取App端指定配置信息
    @RequestMapping("login")
    public String getAppCfg(String key, String defaultValue) {
        return key+"-----"+defaultValue;
    }
    @SaCheckLogin
    @GetMapping("sys/menu")
    public Result getMenu() {
        return  sysMenuService.myselfMenuTree();
    }
    @RequestMapping("/SpCfgApi/getServerCfg")
    public String getServerCfg(@RequestParam("key")String key, @RequestParam("defaultValue")String defaultValue){
        return key+"-----"+defaultValue;
    }
    /**
     * 通过主键查询单条数据
     * @return 单条数据
     */
    @ApiOperation("通过主键查询单条数据")
    @GetMapping("sys/getById/{dictCode}")
    public Result selectOne(@PathVariable String dictCode) {
        return sysDictDetailsService.getBydictId(dictCode);
    }
}
